﻿<shared:PageBase x:Class="Miris.HumanMilkAnalyser.WPF.AnalysisResultSummaryPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:shared="clr-namespace:Miris.HumanMilkAnalyser.WPF.Shared"
      xmlns:interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
      xmlns:userControl="clr-namespace:Miris.HumanMilkAnalyser.WPF.CustomizedUserControl"
      x:Name="CurrentPage"
      mc:Ignorable="d" 
      d:DesignHeight="580" d:DesignWidth="1160"
	  Title="AnalysisResultSummaryPage" Style="{StaticResource DefaultPageStyle}" 
      DataContext="{Binding AnalysisResultSummary, Source={StaticResource Locator}}">
    <Page.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Skins/Storyboard/PageStoryborad.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Page.Resources>
    <Grid HorizontalAlignment="Center">
        <Grid.ColumnDefinitions>
            <!-- Back Button -->
            <ColumnDefinition Width="Auto" />
            <!-- Main Content -->
            <ColumnDefinition Width="Auto" />
            <!-- Next Button -->
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <Button Margin="0,0,30,0" Width="47" Tag="/Skins/Resource/Image/Back.png" Style="{StaticResource OpacityImageButton}" Click="ButtonBack_Click" />
        <!-- Trasparent effect Background -->
        <Border Grid.Column="1" Style="{StaticResource PageContentContainerBorder}">
            <Border Style="{StaticResource PageContentBackgroundBorder}" />
        </Border>
        <Grid Grid.Column="1" Width="1130" Height="550">
            <Grid>
                <Grid.RowDefinitions>
                    <!-- Patient Info & Test Result -->
                    <RowDefinition />
                    <!-- Diagnostic Message -->
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <!-- Mother Info -->
                        <ColumnDefinition Width="Auto" />
                        <!-- Separator -->
                        <ColumnDefinition Width="2" />
                        <!-- Baby Info -->
                        <ColumnDefinition Width="Auto" />
                        <!-- Separator -->
                        <ColumnDefinition Width="2" />
                        <!-- Test Result -->
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid Width="170">
                        <Grid.RowDefinitions>
                            <!-- Title -->
                            <RowDefinition Height="30" />
                            <!-- Content -->
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Border Background="#d7d7d7">
                            <TextBlock Text="母亲信息" HorizontalAlignment="Center" FontSize="16" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                        </Border>
                        <Border Grid.Row="1" BorderThickness="1" BorderBrush="#d7d7d7" Background="White" Padding="6">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <!-- Patient Number -->
                                    <RowDefinition Height="25" />
                                    <!-- Mother Name -->
                                    <RowDefinition Height="25" />
                                    <!-- Mother Age -->
                                    <RowDefinition Height="25" />
                                    <!-- Mother Height -->
                                    <RowDefinition Height="25" />
                                    <!-- Mother Weight -->
                                    <RowDefinition Height="25" />
                                    <!-- BMI -->
                                    <RowDefinition Height="25" />
                                    <!-- Mother Emotion -->
                                    <RowDefinition Height="25" />
                                    <!-- Mother Open Milk Date -->
                                    <RowDefinition Height="25" />
                                    <!-- Mother Delivery Mode -->
                                    <RowDefinition Height="25" />
                                    <!-- MotherBadHabit -->
                                    <RowDefinition Height="25" />
                                </Grid.RowDefinitions>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="编号：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                    <TextBlock Text="{Binding Number}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                </StackPanel>
                                <StackPanel Grid.Row="1" Orientation="Horizontal">
                                    <TextBlock Text="姓名：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                    <TextBlock Text="{Binding MotherName}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                </StackPanel>
                                <StackPanel Grid.Row="2" Orientation="Horizontal">
                                    <TextBlock Text="年龄：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                    <TextBlock Text="{Binding MotherAge}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                </StackPanel>
                                <StackPanel Grid.Row="3" Orientation="Horizontal">
                                    <TextBlock Text="身高(CM)：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                    <TextBlock Text="{Binding MotherHeight}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                </StackPanel>
                                <StackPanel Grid.Row="4" Orientation="Horizontal">
                                    <TextBlock Text="体重(KG)：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                    <TextBlock Text="{Binding MotherWeight}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                </StackPanel>
                                <StackPanel Grid.Row="5" Orientation="Horizontal">
                                    <TextBlock Text="BMI：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                    <TextBlock Text="{Binding MotherBMI}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                </StackPanel>
                                <StackPanel Grid.Row="6" Orientation="Horizontal">
                                    <TextBlock Text="开奶时间：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                    <TextBlock Text="{Binding MotherOpenMilkDateDisplay}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                </StackPanel>
                                <StackPanel Grid.Row="7" Orientation="Horizontal">
                                    <TextBlock Text="分娩方式：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                    <TextBlock Text="{Binding MotherDeliveryMode}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                </StackPanel>
                                <StackPanel Grid.Row="8" Orientation="Horizontal">
                                    <TextBlock Text="情绪：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                    <TextBlock Text="{Binding MotherEmotion}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                </StackPanel>
                                <StackPanel Grid.Row="9" Orientation="Horizontal">
                                    <TextBlock Text="不良习惯：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                    <TextBlock Text="{Binding MotherBadHabit}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                </StackPanel>
                            </Grid>
                        </Border>
                    </Grid>
                    <Grid Grid.Column="2" Width="170">
                        <Grid.RowDefinitions>
                            <!-- Title -->
                            <RowDefinition Height="30" />
                            <!-- Content -->
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Border Background="#d7d7d7">
                            <TextBlock Text="婴儿信息" HorizontalAlignment="Center" FontSize="16" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                        </Border>
                        <Border Grid.Row="1" BorderThickness="1" BorderBrush="#d7d7d7" Background="White" Padding="6">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <!-- Baby Name -->
                                    <RowDefinition Height="25" />
                                    <!-- Baby Gender -->
                                    <RowDefinition Height="25" />
                                    <!-- Baby Birthday -->
                                    <RowDefinition Height="25" />
                                    <!-- Baby Height -->
                                    <RowDefinition Height="25" />
                                    <!-- Baby Weigh -->
                                    <RowDefinition Height="25" />
                                    <!-- Baby Head Circumference -->
                                    <RowDefinition Height="25" />
                                    <!-- Is Baby Premature Delivery -->
                                    <RowDefinition Height="25" />
                                    <!-- Baby Birth Height -->
                                    <RowDefinition Height="25" />
                                    <!-- Baby Birth Weight -->
                                    <RowDefinition Height="25" />
                                    <!-- Baby Birth Head Circumference -->
                                    <RowDefinition Height="25" />
                                    <!-- Apgar -->
                                    <RowDefinition Height="25" />
                                </Grid.RowDefinitions>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="姓名：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                    <TextBlock Text="{Binding BabyName}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                </StackPanel>
                                <StackPanel Grid.Row="1" Orientation="Horizontal">
                                    <TextBlock Text="性别：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                    <TextBlock Text="{Binding BabyGenderDisplay}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                </StackPanel>
                                <StackPanel Grid.Row="2" Orientation="Horizontal">
                                    <TextBlock Text="出生日期：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                    <TextBlock Text="{Binding BabyBirthdayDisplay}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                </StackPanel>
                                <StackPanel Grid.Row="3" Orientation="Horizontal">
                                    <TextBlock Text="身长(CM)：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                    <TextBlock Text="{Binding BabyHeight}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                </StackPanel>
                                <StackPanel Grid.Row="4" Orientation="Horizontal">
                                    <TextBlock Text="体重(KG)：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                    <TextBlock Text="{Binding BabyWeight}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                </StackPanel>
                                <StackPanel Grid.Row="5" Orientation="Horizontal">
                                    <TextBlock Text="头围(CM)：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                    <TextBlock Text="{Binding BabyHeadCircumference}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                </StackPanel>
                                <StackPanel Grid.Row="6" Orientation="Horizontal">
                                    <TextBlock Text="是否早产：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                    <TextBlock Text="{Binding IsBabyPrematureDeliveryDisplay}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                </StackPanel>
                                <StackPanel Grid.Row="7" Orientation="Horizontal">
                                    <TextBlock Text="出生身长(CM)：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                    <TextBlock Text="{Binding BabyBirthHeight}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                </StackPanel>
                                <StackPanel Grid.Row="8" Orientation="Horizontal">
                                    <TextBlock Text="出生体重(KG)：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                    <TextBlock Text="{Binding BabyBirthWeight}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                </StackPanel>
                                <StackPanel Grid.Row="9" Orientation="Horizontal">
                                    <TextBlock Text="出生头围(CM)：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                    <TextBlock Text="{Binding BabyBirthHeadCircumference}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                </StackPanel>
                                <StackPanel Grid.Row="10" Orientation="Horizontal">
                                    <TextBlock Text="Apgar评分：" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                    <TextBlock Text="{Binding Apgar}" Style="{StaticResource AnalysisReportBlackTextBlock}" />
                                </StackPanel>
                            </Grid>
                        </Border>
                    </Grid>
                    <Border Grid.Column="4" Margin="1,0,0,0" BorderThickness="1" BorderBrush="#d7d7d7" Background="White" Padding="20">
                        <ScrollViewer VerticalScrollBarVisibility="Auto" Padding="2">
                            <StackPanel>
                                <userControl:AnalysisResultChartUserControl DataContext="{Binding AllTestResults.Fat}" Height="75" Margin="0,0,0,10" />
                                <userControl:AnalysisResultChartUserControl DataContext="{Binding AllTestResults.CrudeProtein}" Height="75" Margin="0,0,0,10" />
                                <userControl:AnalysisResultChartUserControl DataContext="{Binding AllTestResults.Carbohydrate}" Height="75" Margin="0,0,0,10" />
                                <userControl:AnalysisResultChartUserControl DataContext="{Binding AllTestResults.TS}" Height="75" Margin="0,0,0,10" />
                                <userControl:AnalysisResultChartUserControl DataContext="{Binding AllTestResults.Energy}" Height="75" />
                            </StackPanel>
                        </ScrollViewer>
                    </Border>
                </Grid>
                <StackPanel Grid.Row="1" Margin="0,10,0,0" VerticalAlignment="Bottom">
                    <Grid Height="160">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Border Padding="15">
                            <Border.Background>
                                <ImageBrush ImageSource="/Skins/Resource/Image/GrayBackground.png" />
                            </Border.Background>
                            <ListBox x:Name="PredefinedDiagnosticMessageListBox" BorderThickness="0" 
                                Background="Transparent" ItemsSource="{Binding PredefinedDiagnosticMessageList}">
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding MessageContent}" />
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                                <interactivity:Interaction.Triggers>
                                    <interactivity:EventTrigger EventName="MouseDoubleClick">
                                        <interactivity:InvokeCommandAction Command="{Binding AddDiagnosticMessageCommand}" 
                                                           CommandParameter="{Binding SelectedItem, ElementName=PredefinedDiagnosticMessageListBox}" />
                                    </interactivity:EventTrigger>
                                </interactivity:Interaction.Triggers>
                            </ListBox>
                        </Border>
                        <StackPanel Grid.Column="1" Width="40" VerticalAlignment="Center" HorizontalAlignment="Center">
                            <Button Tag="/Skins/Resource/Image/AddItem.png" HorizontalAlignment="Center" Width="35" 
                            Style="{StaticResource OpacityImageButton}" Command="{Binding AddDiagnosticMessageCommand}" 
                            CommandParameter="{Binding SelectedItem, ElementName=PredefinedDiagnosticMessageListBox}" />
                            <Button Tag="/Skins/Resource/Image/RemoveItem.png" HorizontalAlignment="Center" Width="35" 
                            Style="{StaticResource OpacityImageButton}" Command="{Binding RemoveDiagnosticMessageCommand}" 
                            CommandParameter="{Binding SelectedItem, ElementName=SelectedDiagnosticMessageListBox}" />
                        </StackPanel>
                        <Border Grid.Column="2" Padding="15">
                            <Border.Background>
                                <ImageBrush ImageSource="/Skins/Resource/Image/GrayBackground.png" />
                            </Border.Background>
                            <ListBox x:Name="SelectedDiagnosticMessageListBox" Background="Transparent"
                             BorderThickness="0" ItemsSource="{Binding SelectedDiagnosticMessageList}">
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding MessageContent}" />
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                                <interactivity:Interaction.Triggers>
                                    <interactivity:EventTrigger EventName="MouseDoubleClick">
                                        <interactivity:InvokeCommandAction Command="{Binding RemoveDiagnosticMessageCommand}" 
                                                           CommandParameter="{Binding SelectedItem, ElementName=SelectedDiagnosticMessageListBox}" />
                                    </interactivity:EventTrigger>
                                </interactivity:Interaction.Triggers>
                            </ListBox>
                        </Border>
                        <StackPanel Grid.Column="3">
                            <Button Margin="0,0,0,10" Content="打印" Tag="/Skins/Resource/Image/Print.png" VerticalAlignment="Bottom" HorizontalAlignment="Center" Style="{StaticResource NavigationButton}" Click="ButtonPrint_Click" />
                            <CheckBox Content="打印详细建议" Foreground="Black" Margin="3" FontSize="18" Padding="3" IsChecked="{Binding IncludeBreastfeedingSignificance}" Style="{StaticResource GreenCheckBoxStyle}" />
                        </StackPanel>
                    </Grid>
                    <StackPanel Orientation="Horizontal" Margin="0,10,0,0">
                        <TextBox x:Name="TxtAttachedDiagnosticMessage" Text="{Binding AttachedDiagnosticMessage, Mode=OneWayToSource}" 
                                 Width="935" Height="35" MaxLength="50" Style="{StaticResource InfoTextBox}" />
                        <TextBlock Margin="8,0,0,0" Foreground="White" VerticalAlignment="Center" FontSize="24" Style="{StaticResource AnalysisReportTitleTextBlock}">
                            <TextBlock.Text>
                                <MultiBinding StringFormat="{}{0}/{1}" UpdateSourceTrigger="PropertyChanged">
                                    <Binding ElementName="TxtAttachedDiagnosticMessage" Path="Text.Length" />
                                    <Binding ElementName="TxtAttachedDiagnosticMessage" Path="MaxLength" />
                                </MultiBinding>
                            </TextBlock.Text>
                        </TextBlock>
                    </StackPanel>
                </StackPanel>
            </Grid>
        </Grid>
        <Button Grid.Column="2" Margin="30,0,0,0" Width="47" Tag="/Skins/Resource/Image/Next.png" Style="{StaticResource OpacityImageButton}" Command="{Binding FinishCommand}" />
    </Grid>
</shared:PageBase>
